home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / enemy / HeadBoss.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  24.3 KB  |  762 lines

  1. class classes.enemy.HeadBoss
  2. {
  3.    var x;
  4.    var y;
  5.    var moveScript;
  6.    var id;
  7.    var lifeOrig;
  8.    var clip;
  9.    var trans;
  10.    var colorTrans;
  11.    var dir;
  12.    var flying;
  13.    var axis;
  14.    var xDest;
  15.    var yDest;
  16.    var ep;
  17.    var edge;
  18.    var dc;
  19.    var fireDir;
  20.    var oldDir;
  21.    var xMov = 0;
  22.    var yMov = 0;
  23.    var xMovT = 0;
  24.    var yMovT = 0;
  25.    var speedOrig = 8;
  26.    var speed = 8;
  27.    var f2 = "flying";
  28.    var xDestMet = false;
  29.    var yDestMet = false;
  30.    var c = 0;
  31.    var life = 900;
  32.    var nc = 0;
  33.    var xA = 0;
  34.    var yA = 0;
  35.    var nudging = false;
  36.    var hc = 0;
  37.    var cv = 0.3;
  38.    var intro = true;
  39.    var moveScripting = true;
  40.    var power = 25;
  41.    var wc = 0;
  42.    var armOff = "";
  43.    var Name = "headBoss";
  44.    function HeadBoss(px, py, pmoveScript, pid)
  45.    {
  46.       this.x = px;
  47.       this.y = py;
  48.       this.moveScript = pmoveScript.slice();
  49.       this.id = pid;
  50.       this.speed *= _root.dif.speed;
  51.       this.speedOrig = this.speed;
  52.       this.life *= _root.dif.life;
  53.       this.lifeOrig = this.life;
  54.       _root.d = _root.d + 1;
  55.       this.clip = _root.attachMovie("headBoss","headBoss" + this.id + "Clip",_root.d + 10000);
  56.       this.clip._x = this.x;
  57.       this.clip._y = this.y;
  58.       this.trans = new flash.geom.Transform(this.clip);
  59.       this.colorTrans = new flash.geom.ColorTransform(1,1,1,1,0,0,0,0);
  60.       _root.stats.created = _root.stats.created + 1;
  61.       this.fly();
  62.       this.parseMoveScript();
  63.    }
  64.    function nudge(pxA, pyA, pscale)
  65.    {
  66.       this.nc = 0;
  67.       this.nudging = true;
  68.       var _loc2_ = pscale / 100;
  69.       this.xA = pxA * _loc2_;
  70.       this.yA = pyA * _loc2_;
  71.    }
  72.    function parseMoveScript()
  73.    {
  74.       var _loc2_ = this.dir;
  75.       this.dir = this.moveScript[0];
  76.       if(this.dir == "break")
  77.       {
  78.          delete this.moveScript;
  79.          this.moveScripting = false;
  80.          if(this.flying)
  81.          {
  82.             if(_loc2_ == "L" || _loc2_ == "R")
  83.             {
  84.                this.clip.body["arm" + _loc2_].gotoAndPlay("flyStop");
  85.             }
  86.             this.clip.body.flame.gotoAndStop("still");
  87.             this.speed /= 2;
  88.             this.flying = false;
  89.             this.cv = 0.4;
  90.             this.f2 = "wander";
  91.             this.intro = false;
  92.          }
  93.          this[this.axis + "MovT"] = 0;
  94.          this.f2 = "wander";
  95.          this.newDir();
  96.       }
  97.       else if(this.dir == "summon")
  98.       {
  99.          delete this.moveScript;
  100.          this.moveScripting = false;
  101.          this.xMovT = 0;
  102.          this.yMovT = 0;
  103.          this.c = 0;
  104.          this.f2 = "summoning";
  105.       }
  106.       else
  107.       {
  108.          this[this.axis + "MovT"] = 0;
  109.          this.f2 = "gotoXYDest";
  110.          this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
  111.          this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
  112.          if(this.dir == "L" || this.dir == "U")
  113.          {
  114.             this[this.axis + "Dest"] = Math.round(this[this.axis] - this.moveScript[1]);
  115.          }
  116.          else
  117.          {
  118.             this[this.axis + "Dest"] = Math.round(this[this.axis] + this.moveScript[1]);
  119.          }
  120.          this.moveScript.splice(0,2);
  121.       }
  122.    }
  123.    function gotoXYDest()
  124.    {
  125.       if(Math.abs(this[this.axis + "Dest"] - this[this.axis]) < this.speed + 1)
  126.       {
  127.          if(this.axis == "x")
  128.          {
  129.             this.x = this.xDest;
  130.          }
  131.          else
  132.          {
  133.             this.y = this.yDest;
  134.          }
  135.          this.parseMoveScript();
  136.       }
  137.    }
  138.    function getDirString()
  139.    {
  140.       if(this.xMovT < -1)
  141.       {
  142.          this.dir = "L";
  143.       }
  144.       else if(this.xMovT > 1)
  145.       {
  146.          this.dir = "R";
  147.       }
  148.       else if(this.yMovT > 1)
  149.       {
  150.          this.dir = "D";
  151.       }
  152.       else if(this.yMovT < -1)
  153.       {
  154.          this.dir = "U";
  155.       }
  156.    }
  157.    function fly()
  158.    {
  159.       this.wc = 0;
  160.       this.flying = true;
  161.       this.speed = this.speedOrig * 2;
  162.       if(this.f2 == "wait")
  163.       {
  164.          this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
  165.          this.getDirString();
  166.          this.f2 = "wander";
  167.       }
  168.       this.clip.body["arm" + this.dir].gotoAndPlay("flyStart");
  169.       this.clip.body.flame.gotoAndStop("fly" + this.dir);
  170.       this.clip.body.flame.clip.gotoAndPlay("start");
  171.       this.c = 0;
  172.       this.ep = _root.randRange(10,60);
  173.       this.ep *= _root.dif.speed;
  174.       this.cv = 1 * _root.dif.speed;
  175.    }
  176.    function flyStop()
  177.    {
  178.       if(this.clip.body.armL.flying)
  179.       {
  180.          this.clip.body.armL.gotoAndPlay("flyStop");
  181.       }
  182.       if(this.clip.body.armR.flying)
  183.       {
  184.          this.clip.body.armR.gotoAndPlay("flyStop");
  185.       }
  186.       this.clip.body.flame.gotoAndStop("still");
  187.       this.speed /= 2;
  188.       this.flying = false;
  189.       this.cv = 0.5;
  190.       this.f2 = "wander";
  191.    }
  192.    function newDir()
  193.    {
  194.       if(random(10) > 1)
  195.       {
  196.          this[this.axis + "MovT"] = 0;
  197.          this.dir = _root.getDir(this.x,this.y);
  198.          this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
  199.          this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
  200.       }
  201.       else
  202.       {
  203.          this[this.axis + "MovT"] = 0;
  204.          this.axis = this.axis != "y" ? "y" : "x";
  205.          this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
  206.          this.getDirString();
  207.       }
  208.    }
  209.    function wander()
  210.    {
  211.       if(this.flying)
  212.       {
  213.          this.wc = this.wc + 1;
  214.          if(this.wc > 5 + _root.dif.wait * 2)
  215.          {
  216.             if(random(100) > 95 + _root.dif.wait * 2 && !this.edge)
  217.             {
  218.                this.newDir();
  219.                this.wc = 0;
  220.             }
  221.          }
  222.       }
  223.       else if(random(100) > 91 + _root.dif.wait * 2 && !this.edge)
  224.       {
  225.          if(random(100) > 95)
  226.          {
  227.             this.xMovT = 0;
  228.             this.yMovT = 0;
  229.             this.f2 = "wait";
  230.             this.c = 0;
  231.             this.ep = _root.randRange(20,90);
  232.             this.ep *= 1 / _root.dif.speed;
  233.          }
  234.          else
  235.          {
  236.             this.newDir();
  237.          }
  238.       }
  239.    }
  240.    function wait()
  241.    {
  242.       this.c = this.c + 1;
  243.       if(this.c >= this.ep)
  244.       {
  245.          this.f2 = "wander";
  246.          this.newDir();
  247.       }
  248.       if(random(100) > 95)
  249.       {
  250.          var _loc2_ = ["L","R","F"];
  251.          this.dir = _loc2_[random(_loc2_.length)];
  252.       }
  253.    }
  254.    function death()
  255.    {
  256.       this.dc = this.dc + 1;
  257.       this.xA = _root.randRange2(-1 * this.dc / 40,1 * this.dc / 40);
  258.       this.yA = _root.randRange2(-1 * this.dc / 40,1 * this.dc / 40);
  259.       this.colorTrans.redOffset = _root.randRange(0,this.dc * 3);
  260.       var _loc6_ = _root.randRange(0,this.dc * 2.5);
  261.       this.colorTrans.greenOffset = _root.randRange(0,_loc6_);
  262.       this.colorTrans.blueOffset = _root.randRange(0,_loc6_);
  263.       this.trans.colorTransform = this.colorTrans;
  264.       if(random(3) == 1)
  265.       {
  266.          var _loc5_ = ["red","blue"];
  267.          var _loc8_ = this.x - 20 + this.clip._width / 2 + _root.randRange(-1 * (this.dc / 4),this.dc / 4);
  268.          var _loc7_ = this.y + this.clip._height / 2 + _root.randRange(-1 * (this.dc / 4),this.dc / 4);
  269.          if(random(2) == 1)
  270.          {
  271.             _root.createExploA([_loc8_,_loc7_,_root.randRange(this.dc / 4,this.dc * 1),_root.randRange(0,50),"Red"]);
  272.          }
  273.          _root["gunSmoke" + this.dc] = new classes.fx.GunSmoke(_loc8_,_loc7_,this.dc);
  274.          _root.addFX("gunSmoke" + this.dc);
  275.       }
  276.       if(this.dc == 1)
  277.       {
  278.          _root.aC1.s1.stop();
  279.          _root.audio.playLevel2("headBossEnd",35);
  280.          var _loc3_ = 1;
  281.          var _loc4_ = _root.chars.length;
  282.          _loc5_ = _root.chars.slice();
  283.          while(_loc3_ < _loc4_)
  284.          {
  285.             _root[_loc5_[_loc3_]].bombed(20);
  286.             _loc3_ = _loc3_ + 1;
  287.          }
  288.          _loc3_ = 0;
  289.          _loc4_ = _root.enemyShots.length;
  290.          _loc5_ = _root.enemyShots.slice();
  291.          while(_loc3_ < _loc4_)
  292.          {
  293.             _root[_loc5_[_loc3_]].bombed();
  294.             _loc3_ = _loc3_ + 1;
  295.          }
  296.          this.xMovT = 0;
  297.          this.yMovT = 0;
  298.          this.clip.body.armL.gotoAndPlay("death");
  299.          this.clip.body.armR.gotoAndPlay("death");
  300.          this.clip.body.eyes.gotoAndPlay("death");
  301.          this.clip.body.flame.gotoAndStop("still");
  302.       }
  303.       if(this.dc == 100)
  304.       {
  305.          this.clip.body.armL.gotoAndPlay("death2");
  306.          this.clip.body.armR.gotoAndPlay("death2");
  307.       }
  308.       if(this.dc == 150)
  309.       {
  310.          _root.audio.playLevel2("headBossX",40);
  311.          _loc3_ = 0;
  312.          _loc4_ = _root.randRange(5,8);
  313.          while(_loc3_ < _loc4_)
  314.          {
  315.             _root.createExploA([this.x + this.clip._width / 2 + _root.randRange(-50,50),this.y + this.clip._height / 2 + _root.randRange(-50,50),_root.randRange(80,150),_root.randRange(75,100),"Blue"]);
  316.             _loc3_ = _loc3_ + 1;
  317.          }
  318.          _loc3_ = 0;
  319.          _loc4_ = _root.randRange(8,12);
  320.          while(_loc3_ < _loc4_)
  321.          {
  322.             _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"headBoss","Blue",true]);
  323.             _loc3_ = _loc3_ + 1;
  324.          }
  325.          _root.createPowerUp([this.x,this.y,"coin5"]);
  326.          _root.createPowerUp([this.x,this.y,"coin5"]);
  327.          _root.createPowerUp([this.x,this.y,"coin10"]);
  328.          _root.createPowerUp([this.x,this.y,"coin10"]);
  329.          _loc3_ = 0;
  330.          while(_loc3_ < 2)
  331.          {
  332.             _root.createPowerUp([this.x,this.y,"coin25"]);
  333.             _loc3_ = _loc3_ + 1;
  334.          }
  335.          _root.createPowerUp([this.x,this.y,"lifeMax"]);
  336.          _root.createPowerUp([this.x,this.y,"shield"]);
  337.          _root.boss = false;
  338.          _root.initLevel3();
  339.          _root.stats.destroyed = _root.stats.destroyed + 1;
  340.          _root.stats.score += 250000;
  341.          _root.removeChar("headBoss" + this.id);
  342.          this.f2 = "";
  343.       }
  344.    }
  345.    function fire()
  346.    {
  347.       this.f2 = "firing";
  348.       this.xMovT = 0;
  349.       this.yMovT = 0;
  350.       this.c = 0;
  351.    }
  352.    function firing()
  353.    {
  354.       this.c = this.c + 1;
  355.       if(this.c == 2)
  356.       {
  357.          this.fireDir = this.x <= _root[_root.char].x ? "R" : "L";
  358.          if(this.fireDir == this.armOff)
  359.          {
  360.             this.f2 = "wander";
  361.             this.newDir();
  362.          }
  363.          else
  364.          {
  365.             _root.audio.playLevel2("headBossFire",30);
  366.          }
  367.       }
  368.       if(this.c == 15)
  369.       {
  370.          this.clip.body["arm" + this.fireDir].gotoAndPlay("fire");
  371.       }
  372.       if(this.c == 33)
  373.       {
  374.          var _loc5_ = Math.ceil(Math.abs((this.y - _root[_root.char].y) / 100));
  375.          var _loc3_ = 0;
  376.          var _loc6_ = this.fireDir != "L" ? this.x + 21 : this.x - 33;
  377.          var _loc8_ = this.y + 9;
  378.          var _loc7_ = this.fireDir != "L" ? 6 : -6;
  379.          while(_loc3_ < 5)
  380.          {
  381.             var _loc4_ = (_loc5_ * -2 + _loc5_ * _loc3_) * 1.5;
  382.             _root.enemyShotID = _root.enemyShotID + 1;
  383.             _root["headBossBlastA" + _root.enemyShotID] = new classes.shots.HeadBossBlastA(_loc6_,_loc8_,_loc7_,_loc4_,_root.enemyShotID);
  384.             _root.addEnemyShot("headBossBlastA" + _root.enemyShotID);
  385.             _loc3_ = _loc3_ + 1;
  386.          }
  387.       }
  388.       if(this.c == 45)
  389.       {
  390.          this.f2 = "wander";
  391.          this.newDir();
  392.       }
  393.    }
  394.    function summon()
  395.    {
  396.       this.moveScripting = true;
  397.       this.moveScript = [];
  398.       if(this.y - 300 >= 0)
  399.       {
  400.          this.moveScript.push("U");
  401.       }
  402.       else
  403.       {
  404.          this.moveScript.push("D");
  405.       }
  406.       this.moveScript.push(Math.round(Math.abs(this.y - 300)));
  407.       if(this.x - 500 >= 0)
  408.       {
  409.          this.moveScript.push("L");
  410.       }
  411.       else
  412.       {
  413.          this.moveScript.push("R");
  414.       }
  415.       this.moveScript.push(Math.round(Math.abs(this.x - 500)));
  416.       this.moveScript.push("summon");
  417.       this.parseMoveScript();
  418.    }
  419.    function summoning()
  420.    {
  421.       this.c = this.c + 1;
  422.       if(this.c == 10)
  423.       {
  424.          this.clip.body.armL.gotoAndPlay("summon");
  425.          this.clip.body.armR.gotoAndPlay("summon");
  426.          this.clip.body.eyes.gotoAndStop("F");
  427.          this.clip.body.eyes.clip.gotoAndPlay("glow");
  428.          this.clip.body.brain.gotoAndPlay("glow");
  429.          _root.audio.playLevel2("headBossSummon",30);
  430.       }
  431.       if(this.c == 20)
  432.       {
  433.          var _loc3_ = random(6);
  434.          if(_loc3_ == 0)
  435.          {
  436.             _root.createHeadSummon(["A",[this.x - 75,this.y + 10,["break"]]]);
  437.             _root.createHeadSummon(["A",[this.x + 95,this.y + 10,["break"]]]);
  438.             _root.createHeadSummon(["A",[this.x,this.y - 75,["break"]]]);
  439.             _root.createHeadSummon(["A",[this.x,this.y + 100,["break"]]]);
  440.          }
  441.          else if(_loc3_ == 1)
  442.          {
  443.             _root.createHeadSummon(["A",[this.x - 75,this.y + 10,["break"]]]);
  444.             _root.createHeadSummon(["A",[this.x + 95,this.y + 10,["break"]]]);
  445.             _root.createHeadSummon(["A",[this.x,this.y - 75,["break"]]]);
  446.             _root.createHeadSummon(["A",[this.x,this.y + 100,["break"]]]);
  447.             _root.createHeadSummon(["A",[this.x - 60,this.y - 60,["break"]]]);
  448.             _root.createHeadSummon(["A",[this.x + 80,this.y - 60,["break"]]]);
  449.             _root.createHeadSummon(["A",[this.x + 80,this.y + 80,["break"]]]);
  450.             _root.createHeadSummon(["A",[this.x - 60,this.y + 80,["break"]]]);
  451.          }
  452.          else if(_loc3_ == 2)
  453.          {
  454.             _root.createHeadSummon(["B",[this.x - 75,this.y + 10,["break"]]]);
  455.             _root.createHeadSummon(["B",[this.x + 95,this.y + 10,["break"]]]);
  456.             _root.createHeadSummon(["B",[this.x,this.y - 75,["break"]]]);
  457.             _root.createHeadSummon(["B",[this.x,this.y + 100,["break"]]]);
  458.          }
  459.          else if(_loc3_ == 3)
  460.          {
  461.             _root.createHeadSummon(["B",[this.x - 75,this.y + 10,["break"]]]);
  462.             _root.createHeadSummon(["B",[this.x + 95,this.y + 10,["break"]]]);
  463.             _root.createHeadSummon(["B",[this.x,this.y - 75,["break"]]]);
  464.             _root.createHeadSummon(["B",[this.x,this.y + 100,["break"]]]);
  465.             _root.createHeadSummon(["B",[this.x - 60,this.y - 60,["break"]]]);
  466.             _root.createHeadSummon(["B",[this.x + 80,this.y - 60,["break"]]]);
  467.             _root.createHeadSummon(["B",[this.x + 80,this.y + 80,["break"]]]);
  468.             _root.createHeadSummon(["B",[this.x - 60,this.y + 80,["break"]]]);
  469.          }
  470.          else if(_loc3_ == 4)
  471.          {
  472.             _root.createHeadSummon(["C",[this.x - 75,this.y + 10,["break"]]]);
  473.             _root.createHeadSummon(["C",[this.x + 95,this.y + 10,["break"]]]);
  474.             _root.createHeadSummon(["C",[this.x,this.y - 75,["break"]]]);
  475.             _root.createHeadSummon(["C",[this.x,this.y + 100,["break"]]]);
  476.          }
  477.          else
  478.          {
  479.             _root.createHeadSummon(["C",[this.x - 75,this.y + 10,["break"]]]);
  480.             _root.createHeadSummon(["C",[this.x + 95,this.y + 10,["break"]]]);
  481.             _root.createHeadSummon(["C",[this.x,this.y - 75,["break"]]]);
  482.             _root.createHeadSummon(["C",[this.x,this.y + 100,["break"]]]);
  483.             _root.createHeadSummon(["C",[this.x - 60,this.y - 60,["break"]]]);
  484.             _root.createHeadSummon(["C",[this.x + 80,this.y - 60,["break"]]]);
  485.             _root.createHeadSummon(["C",[this.x + 80,this.y + 80,["break"]]]);
  486.             _root.createHeadSummon(["C",[this.x - 60,this.y + 80,["break"]]]);
  487.          }
  488.       }
  489.       if(this.c == 45)
  490.       {
  491.          this.f2 = "wander";
  492.          this.newDir();
  493.       }
  494.    }
  495.    function main()
  496.    {
  497.       _root.f2 = this.f2;
  498.       _root.flying = this.flying;
  499.       this[this.f2]();
  500.       if(this.flying)
  501.       {
  502.          if(!this.moveScripting)
  503.          {
  504.             this.c = this.c + 1;
  505.             if(this.c >= this.ep)
  506.             {
  507.                this.flyStop();
  508.             }
  509.          }
  510.       }
  511.       if(this.oldDir != this.dir)
  512.       {
  513.          _root.oldDir = this.oldDir;
  514.          _root.dir = this.dir;
  515.          if(this.oldDir == undefined || this.dir == "F")
  516.          {
  517.             this.clip.body.eyes.gotoAndStop(this.dir);
  518.          }
  519.          else if(this.dir == "U" || this.dir == "D")
  520.          {
  521.             this.clip.body.eyes.gotoAndStop(this.oldDir);
  522.          }
  523.          else if(random(3) > 0)
  524.          {
  525.             if(this.dir == "R")
  526.             {
  527.                this.clip.body.eyes.gotoAndPlay("LtoR");
  528.             }
  529.             else
  530.             {
  531.                this.clip.body.eyes.gotoAndPlay("RtoL");
  532.             }
  533.          }
  534.          else
  535.          {
  536.             this.clip.body.eyes.gotoAndPlay("spin" + this.dir);
  537.          }
  538.          if(this.flying)
  539.          {
  540.             this.clip.body.flame.gotoAndStop("fly" + this.dir);
  541.             if(this.oldDir == "U" || this.oldDir == "D")
  542.             {
  543.                if(this.dir == "L" || this.dir == "R")
  544.                {
  545.                   this.clip.body["arm" + this.dir].gotoAndPlay("flyStart");
  546.                }
  547.             }
  548.             else if(this.dir == "U" || this.dir == "D")
  549.             {
  550.                this.clip.body["arm" + this.oldDir].gotoAndPlay("flyStop");
  551.             }
  552.             else
  553.             {
  554.                this.clip.body["arm" + this.oldDir].gotoAndPlay("flyStop");
  555.                this.clip.body["arm" + this.dir].gotoAndPlay("flyStart");
  556.             }
  557.          }
  558.       }
  559.       this.oldDir = this.dir;
  560.       if(random(100) > 96 + _root.dif.wait && this.f2 != "death")
  561.       {
  562.          if(!this.moveScripting && !this.flying && this.f2 != "summoning" && this.f2 != "firing" && !this.edge)
  563.          {
  564.             var _loc9_ = random(10);
  565.             if(_loc9_ < 3)
  566.             {
  567.                this.fly();
  568.             }
  569.             else if(_loc9_ >= 3 && _loc9_ < 6)
  570.             {
  571.                if(_root.chars.length < 12)
  572.                {
  573.                   this.summon();
  574.                }
  575.             }
  576.             else
  577.             {
  578.                this.fire();
  579.             }
  580.          }
  581.       }
  582.       if(this.nudging)
  583.       {
  584.          this.xA *= 0.5;
  585.          this.yA *= 0.5;
  586.          this.nc = this.nc + 1;
  587.          var _loc10_ = 255 - this.nc * 17;
  588.          this.colorTrans.redOffset = _loc10_;
  589.          this.trans.colorTransform = this.colorTrans;
  590.          if(this.nc == 15)
  591.          {
  592.             this.xA = this.yA = 0;
  593.             this.nudging = false;
  594.             this.colorTrans.redOffset = 0;
  595.             this.trans.colorTransform = this.colorTrans;
  596.          }
  597.       }
  598.       var _loc4_ = 0;
  599.       var _loc5_ = _root.broShots.length;
  600.       while(_loc4_ < _loc5_)
  601.       {
  602.          var _loc7_ = _root.broShots[_loc4_] + "Clip";
  603.          if(this.clip.hitTest(_root[_loc7_]))
  604.          {
  605.             if(this.x < 950 && this.x > 0 && this.y > 0 && this.y < 550 && this.f2 != "death")
  606.             {
  607.                var _loc3_ = _root.broShots[_loc4_];
  608.                var _loc6_ = this.life;
  609.                this.life -= _root[_loc3_].power;
  610.                this.clip.body.d1.gotoAndStop(Math.ceil((100 - this.life / this.lifeOrig * 100) / 20));
  611.                if(this.clip.body.d1._currentframe == 5 && this.armOff == "")
  612.                {
  613.                   this.armOff = random(2) != 0 ? "R" : "L";
  614.                   this.clip.body["arm" + this.armOff]._visible = false;
  615.                   _root.audio.playLevel2("headBossX",20);
  616.                   _loc4_ = 0;
  617.                   _loc5_ = _root.randRange(3,5);
  618.                   while(_loc4_ < _loc5_)
  619.                   {
  620.                      _root.createExploA([this.x + this.clip._width / 2 + _root.randRange(-25,25),this.y + this.clip._height / 2 + _root.randRange(-25,25),_root.randRange(50,80),_root.randRange(75,100),"Red"]);
  621.                      _loc4_ = _loc4_ + 1;
  622.                   }
  623.                   _loc4_ = 0;
  624.                   _loc5_ = _root.randRange(2,4);
  625.                   while(_loc4_ < _loc5_)
  626.                   {
  627.                      _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"headBossArmA"]);
  628.                      _loc4_ = _loc4_ + 1;
  629.                   }
  630.                   _root.createShrapnel([this.x + this.clip._width / 2,this.y + this.clip._height / 2,"headBossArmB"]);
  631.                }
  632.                if(this.life < 1)
  633.                {
  634.                   this.f2 = "death";
  635.                   this.dc = 0;
  636.                }
  637.                else
  638.                {
  639.                   this.nudge(_root[_loc3_].xMov,_root[_loc3_].yMov,10);
  640.                   _root.audio.playLevel4("headHit" + (random(4) + 1),_root.randRange(10,25));
  641.                   if(random(10) > 7)
  642.                   {
  643.                      var _loc12_ = this.x - 20 + this.clip._width / 2 + _root.randRange(-20,20);
  644.                      var _loc11_ = this.y + this.clip._height / 2 + _root.randRange(-20,20);
  645.                      _root.fxID = _root.fxID + 1;
  646.                      _root["gunSmoke" + _root.fxID] = new classes.fx.GunSmoke(_loc12_,_loc11_,_root.fxID);
  647.                      _root.addFX("gunSmoke" + _root.fxID);
  648.                   }
  649.                   if(!this.moveScripting && this.f2 != "summoning" && this.f2 != "firing")
  650.                   {
  651.                      this[this.axis + "MovT"] = 0;
  652.                      this.axis = this.axis != "y" ? "y" : "x";
  653.                      this[this.axis + "MovT"] = random(2) <= 0 ? -1 * this.speed : this.speed;
  654.                      this.getDirString();
  655.                      if(random(10) > 8)
  656.                      {
  657.                         this.fly();
  658.                      }
  659.                   }
  660.                }
  661.             }
  662.             _root[_root.char].fc = _root[_root.char].fireFreq - _root.rapidVar;
  663.             _root[_loc3_].exploX = this.x + this.clip._width / 2;
  664.             _root[_loc3_].exploY = this.y + this.clip._height / 2;
  665.             _root[_loc3_].hit(_loc6_);
  666.          }
  667.          _loc4_ = _loc4_ + 1;
  668.       }
  669.       if(this.clip.hitTest(_root[_root.char + "Clip"]))
  670.       {
  671.          _root[_root.char].hit(this.xMov,this.yMov,100,this.power);
  672.       }
  673.       if(!this.intro)
  674.       {
  675.          this.edge = false;
  676.          if(this.x > 800)
  677.          {
  678.             this.edge = true;
  679.             this.dir = "L";
  680.          }
  681.          else if(this.x < 200)
  682.          {
  683.             this.edge = true;
  684.             this.dir = "R";
  685.          }
  686.          else if(this.y < 150)
  687.          {
  688.             this.edge = true;
  689.             this.dir = "D";
  690.          }
  691.          else if(this.y > 450)
  692.          {
  693.             this.edge = true;
  694.             this.dir = "U";
  695.          }
  696.          if(this.edge)
  697.          {
  698.             this[this.axis + "MovT"] = 0;
  699.             this.axis = !(this.dir == "L" || this.dir == "R") ? "y" : "x";
  700.             this[this.axis + "MovT"] = !(this.dir == "L" || this.dir == "U") ? this.speed : -1 * this.speed;
  701.             this.getDirString();
  702.          }
  703.       }
  704.       if(this.xMovT < this.xMov)
  705.       {
  706.          this.xMov -= this.cv;
  707.       }
  708.       else if(this.xMovT > this.xMov)
  709.       {
  710.          this.xMov += this.cv;
  711.       }
  712.       else
  713.       {
  714.          this.xMov = this.xMovT;
  715.       }
  716.       if(this.yMovT < this.yMov)
  717.       {
  718.          this.yMov -= this.cv;
  719.       }
  720.       else if(this.yMovT > this.yMov)
  721.       {
  722.          this.yMov += this.cv;
  723.       }
  724.       else
  725.       {
  726.          this.yMov = this.yMovT;
  727.       }
  728.       if(random(100) > 98)
  729.       {
  730.          if(this.f2 != "summoning")
  731.          {
  732.             this.clip.body.eyes.clip.gotoAndPlay("blink");
  733.          }
  734.       }
  735.       var _loc8_ = this.life - 500;
  736.       if(_loc8_ < 0)
  737.       {
  738.          _loc8_ = 8;
  739.       }
  740.       if(_loc8_ < -250)
  741.       {
  742.          _loc8_ = 3;
  743.       }
  744.       if(_loc8_ < -400)
  745.       {
  746.          _loc8_ = 1;
  747.       }
  748.       if(random(_loc8_) == 0)
  749.       {
  750.          _loc12_ = this.x - 20 + this.clip._width / 2 + _root.randRange(-20,20);
  751.          _loc11_ = this.y + this.clip._height / 2 + _root.randRange(-20,20);
  752.          _root.fxID = _root.fxID + 1;
  753.          _root["gunSmoke" + _root.fxID] = new classes.fx.GunSmoke(_loc12_,_loc11_,_root.fxID);
  754.          _root.addFX("gunSmoke" + _root.fxID);
  755.       }
  756.       this.x += this.xMov + this.xA;
  757.       this.y += this.yMov + this.yA + 0.5 * Math.sin(this.hc += 0.08);
  758.       this.clip._x = this.x;
  759.       this.clip._y = this.y;
  760.    }
  761. }
  762.